import { mock, ok } from '@/utils/requestMock';

// 空间数据管理树
mock('GET', '/GIS/GISDataAreaTree', () => ([
  { task_name: 'CE3', data_set_list: [
    { data_set_name: 'LPR 2B', key: 'ce3_lpr_2b' },
    { data_set_name: 'PIXS 2B', key: 'ce3_pixs_2b' }
  ]},
  { task_name: 'CE4', data_set_list: [
    { data_set_name: 'APXS 2B', key: 'ce4_apxs_2b' },
    { data_set_name: 'VNIR 2B', key: 'ce4_vnir_2b' }
  ]}
]));

// 空间数据管理列表
mock('GET', '/GIS/GISDataArea', (config) => {
  const page = parseInt(config.params?.page) || 1;
  const pageSize = parseInt(config.params?.page_size) || 20;
  const allData = Array.from({ length: 8 }).map((_, i) => ({
    id: i + 1,
    planet_id: 1,
    task: i % 2 === 0 ? 'CE3' : 'CE4',
    task_zh: i % 2 === 0 ? '嫦娥三号' : '嫦娥四号',
    data_type: 'IMG',
    data_level: 'L2B',
    area_level: 'A1',
    area_name: `区域_${i + 1}`,
    left_latitude: 70 - i,
    left_longitude: -180 + i,
    right_latitude: -7 + i,
    right_longitude: 180 - i,
    files: `/path/to/file_${i + 1}.tif`,
    create_time: '2025-01-15 10:30:00',
    update_time: '2025-01-15 10:30:00'
  }));
  const startIndex = (page - 1) * pageSize;
  const endIndex = startIndex + pageSize;
  const list = allData.slice(startIndex, endIndex);
  return {
    count: allData.length,
    list,
    page,
    pages: Math.ceil(allData.length / pageSize),
    page_size: pageSize
  };
});

// 新建/更新/删除
mock('POST', '/GIS/GISDataArea', () => ok());
mock('POST', '/GIS/GISDataAreaUpdate', () => ok());
mock('POST', '/GIS/GISDataAreaDelete', () => ok());


